package cn.langpy.kotime.config;

import com.alibaba.ttl.threadpool.TtlExecutors;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 *
 * @author: thx
 * @date: 2022/5/22 23:30
 */
@Configuration
public class TtlConfig {

    /**
     * ttl 处理线程池数据传递BUG<br/>
     * 如需其他ScheduledExecutorService/Executor/ThreadFactory等参考TtlExecutors.getXX
     * @return
     */
    @Bean
    public ExecutorService ttlExecutorService() {
        return TtlExecutors.getTtlExecutorService(Executors.newCachedThreadPool());
    }

}
